﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>NewsAdminNodeForm</title>
    <script type="text/javascript">
    </script>
    <style type="text/css">
    </style>
</head>
<body>
<form id="formx" name="formx" method="post" enctype="multipart/form-data">
<div class="easyui-layout" data-options="fit:true," style="padding: 0px;">
    <div data-options="region:'north',split:false," style="height: 30px; padding: 1px; overflow: hidden;">
        <div id="dlg-toolbar">
            <div style="float: left;">
                <a id="btnSave" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true,">保存</a>
                <a id="btnHelp" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-help',plain:true,">帮助</a>
                <a id="btnClose" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-no',plain:true,">关闭</a>
            </div>
            <div style="float: right; padding: 2px 1px 0px 2px;"><input class="easyui-searchbox" data-options="prompt:'关键字'" style="width: 150px" /></div>
        </div>
    </div>
    <div data-options="region:'center'," style="padding: 1px;">
        <div class="easyui-tabs" data-options="tools:'#tab-tools1',fit:true,border:true,">
            <div title="基本管理" style="padding: 1px;">
                <div class="easyui-layout" data-options="fit:true,">
                    <div data-options="region:'north',split:false," style="height: 130px; padding: 1px; overflow: hidden;">
                        <div class="easyui-layout" data-options="fit:true,">
                            <div data-options="region:'center',split:false," style="padding: 1px; overflow: hidden;">
                                <dl class="rowshalf rows2">
                                    <dd><div class="left line-height-auto">节点名称：</div><div class="right line-height-auto"><input id="Title" name="Title" class="easyui-textbox" style="width: 100%;" type="text" data-options="required:false,prompt:'节点名称'," /></div></dd>
                                    <dd><div class="left line-height-auto">文 件 夹：</div><div class="right line-height-auto"><input id="Folder" name="Folder" class="easyui-textbox" style="width: 100%;" type="text" data-options="required:false,prompt:'输入路径名称，建议使用：英文字母、数字。'," /></div></dd>
                                </dl>
                                <dl class="rowshalf rows2">
                                    <dd><div class="left line-height-auto">链接地址：</div><div class="right line-height-auto"><input id="Url" name="Url" class="easyui-textbox" style="width: 100%;" type="text" data-options="required:false,prompt:'输入网址，如：http://www.baidu.com/。'," /></div></dd>
                                    <dd><div class="left line-height-auto">启用链接：</div><div class="right line-height-auto"><input id="FlagTop" type="checkbox" value="1" /></div></dd>
                                </dl>
                                <dl class="rowshalf rows2">
                                    <dd><div class="left line-height-auto">CSS样式：</div><div class="right line-height-auto" style="margin-bottom: 1px;"><input id="CssName" name="CssName" class="easyui-textbox" style="width: 100%;" type="text" data-options="required:false,prompt:'输入样式名称，需用css配合前台实现。'," /></div></dd>
                                    <dd><div class="left line-height-auto">英 文 名：</div><div class="right line-height-auto" style="margin-bottom: 1px;"><input id="TitleEn" name="TitleEn" class="easyui-textbox" style="width: 100%;" type="text" data-options="required:false,prompt:'英文名称，可能有特殊用途。'," /></div></dd>
                                </dl>
                            </div>
                            <div data-options="region:'east',split:false," style="width: 320px; padding: 1px; overflow: hidden;">
                                <div class="rows2">
                                    <div class="left line-height-auto">访问状态：</div>
                                    <div class="right" style="margin-bottom: 1px; padding-top: 6px;">
                                        <input id="FlagStatus1" name="FlagStatus" type="radio" value="0" /> 未审
                                        <input id="FlagStatus2" name="FlagStatus" type="radio" value="1" /> 已审
                                        <input id="FlagStatus3" name="FlagStatus" type="radio" value="2" /> 停止
                                    </div>
                                </div>
                                <div class="rows2">
                                    <div class="left line-height-auto">菜单显示：</div>
                                    <div class="right" style="margin-bottom: 1px; padding-top: 6px;">
                                        <input id="flagMenu1" name="flagMenu" type="radio" value="1" /> 是
                                        <input id="flagMenu2" name="flagMenu" type="radio" value="0" /> 否
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div data-options="region:'center',split:true," style="padding: 1px; overflow: hidden;">
                        <div id="tabsContent" class="easyui-tabs" data-options="fix:true,plain:false,height:'100%',tabPosition:'top'," style="width: 100%; height: 100%; border: 0px solid #ff0000;">
                            <div title="节点说明" id="tabsIndex" class="tabsIndex"><textarea id="Content" name="Content" style="width: 100%; height: 100%; padding: 10px;"></textarea></div>
                        </div>
                    </div>
                </div>
            </div>
            <div title="模板指定" style="padding: 1px">
                <div id="NodeTemplate" class="easyui-panel" data-options="title:'节点模板',iconCls:'icon-acc'," style="width: 100%; height: 100%;">
                    <table class="nowraptd" style="width: 100%; height: auto; border-collapse: collapse; border: 1px;">
                        <tr>
                            <td style="width: 64px;">&nbsp;首页：</td>
                            <td><input id="TemplateIndex" name="TemplateIndex" class="easyui-textbox" style="width: 100%;" type="text" data-options="required:false," /></td>
                            <td style="width: 120px;">&nbsp;TemplateIndex</td>
                        </tr>
                        <tr>
                            <td style="width: 64px;">&nbsp;节点页：</td>
                            <td><input id="TemplateNode" name="TemplateNode" class="easyui-textbox" style="width: 100%;" type="text" data-options="required:false," /></td>
                            <td style="width: 120px;">&nbsp;TemplateNode</td>
                        </tr>
                        <tr>
                            <td style="width: 64px;">&nbsp;列表页：</td>
                            <td><input id="TemplateList" name="TemplateList" class="easyui-textbox" style="width: 100%;" type="text" data-options="required:false," /></td>
                            <td style="width: 120px;">&nbsp;TemplateList</td>
                        </tr>
                        <tr>
                            <td style="width: 64px;">&nbsp;内容页：</td>
                            <td><input id="TemplateView" name="TemplateView" class="easyui-textbox" style="width: 100%;" type="text" data-options="required:false," /></td>
                            <td style="width: 120px;">&nbsp;TemplateView</td>
                        </tr>
                    </table>
                </div>
            </div>
            <div title="字段定义" style="padding: 1px">
                <div class="easyui-layout" data-options="fit:true,">
                    <div data-options="title:'基本扩展（超过下列个数的请用“自定义字段扩展”）',region:'north',split:false," style="height: 150px; padding: 1px;  overflow-x: hidden; overflow-y: scroll;">
                        <fieldset class="fieldsetCSS1">
                            <legend>整型字段</legend>
                            <p>字段1-备注：<input id="KeyInt1" name="KeyInt1" class="easyui-textbox key1" /></p>
                            <p>字段2-备注：<input id="KeyInt2" name="KeyInt2" class="easyui-textbox key1" /></p>
                            <p>字段3-备注：<input id="KeyInt3" name="KeyInt3" class="easyui-textbox key1" /></p>
                        </fieldset>
                        <fieldset class="fieldsetCSS1">
                            <legend>字符串字段</legend>
                            <p>字段1-备注：<input id="KeyString1" name="KeyString1" class="easyui-textbox key1" /></p>
                            <p>字段2-备注：<input id="KeyString2" name="KeyString2" class="easyui-textbox key1" /></p>
                            <p>字段3-备注：<input id="KeyString3" name="KeyString3" class="easyui-textbox key1" /></p>
                        </fieldset>
                        <fieldset class="fieldsetCSS1">
                            <legend>浮点型字段</legend>
                            <p>字段1-备注：<input id="KeyFloat1" name="KeyFloat1" class="easyui-textbox key1" /></p>
                            <p>字段2-备注：<input id="KeyFloat2" name="KeyFloat2" class="easyui-textbox key1" /></p>
                            <p>字段3-备注：<input id="KeyFloat3" name="KeyFloat3" class="easyui-textbox key1" /></p>
                        </fieldset>
                        <fieldset class="fieldsetCSS1">
                            <legend>日期型字段</legend>
                            <p>字段1-备注：<input id="KeyDateTime1" name="KeyDateTime1" class="easyui-textbox key1" /></p>
                            <p>字段2-备注：<input id="KeyDateTime2" name="KeyDateTime2" class="easyui-textbox key1" /></p>
                            <p>字段3-备注：<input id="KeyDateTime3" name="KeyDateTime3" class="easyui-textbox key1" /></p>
                        </fieldset>
                    </div>
                    <div data-options="title:'自定义字段扩展列表【限本节点】',region:'center',split:true," style="padding: 1px;">
                        <div class="easyui-layout" data-options="fit:true,">
                            <div data-options="region:'north',split:false," style="height: 30px; overflow: hidden;">
                                <div style="float: left;">
                                    <a href="javascript:void(0)" class="easyui-linkbutton mp0" id="siteNew" data-options="iconCls:'icon-add1',plain:true,"></a>
                                    <a href="#" class="easyui-menubutton" data-options="menu:'#mmField',iconCls:'icon-edit',"></a>
                                    <div id="mmField" style="width: 150px;">
                                        <div id="siteEdit">编辑（双击）</div>
                                        <div data-options="iconCls:'icon-cancel'">删除</div>
                                        <div data-options="iconCls:'icon-stop'">停止</div>
                                        <div class="menu-sep"></div>
                                        <div id="sortYes">可排序</div>
                                        <div id="sortSave">保存排序</div>
                                        <div class="menu-sep"></div>
                                        <div data-options="disabled:true,">全选</div>
                                        <div data-options="disabled:true,">反选</div>
                                        <div data-options="disabled:true,">不选</div>
                                    </div>
                                </div>
                                <div style="float: right; padding: 2px 1px 0px 2px;">
                                </div>
                            </div>
                            <div data-options="region:'center',split:true," style="padding: 1px;">
                                <table id="datagridfield" class="easyui-datagrid" style="width: 100%; height: 100%;" data-options="title:'',iconCls:'icon-group',rownumbers:true,pagination:true,singleSelect:true,
                                    url:'/Ashx/Acc/Staff/NewsAdminInfoList.ashx',method:'post',autoRowHeight:true,toolbar:'#tbs',onLoadSuccess:function(){$(this).datagrid('enableDnd');},">
                                    <thead>
                                        <tr>
                                            <th data-options="field:'ck',checkbox:true,"></th>
                                            <th data-options="field:'PkId',halign:'center',">ID</th>
                                            <th data-options="field:'Tag',halign:'center',">所属节点</th>
                                            <th data-options="field:'Title',halign:'center',">标题</th>
                                            <th data-options="field:'DateTimeCreate',halign:'center',formatter:window.xbase.FormatDateTime,">时间</th>
                                            <th data-options="field:'FlagStatus',halign:'center',formatter:window.xbase.FormatUserFlagStatus,">状态</th>
                                        </tr>
                                    </thead>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div title="节点配图" style="padding: 1px">
                <div class="easyui-layout" data-options="fit:true,">
                    <div data-options="region:'north',split:false,title:'引导图'," style="height: 30%; height: 160px; overflow: hidden; padding: 1px;">
                        <div class="easyui-layout" data-options="fit:true,">
                            <div data-options="region:'north',split:false," style="height: 30px; overflow: hidden;">
                                <div style="float: left;">
                                    <a href="javascript:void(0)" class="easyui-linkbutton mp0" id="GuideAdd" data-options="iconCls:'icon-add1',plain:true,"></a>
                                    <a href="#" class="easyui-menubutton" data-options="menu:'#mmGuide',iconCls:'icon-edit',"></a>
                                    <div id="mmGuide" style="width: 150px;">
                                        <div id="GuideDelete" data-options="iconCls:'icon-cancel'">删除</div>
                                    </div>
                                </div>
                                <div style="float: right; padding: 2px 1px 0px 2px;">
                                </div>
                            </div>
                            <div data-options="region:'center',split:true," style="padding: 1px; text-align: center; overflow: auto;">
                                <input id="Guide" name="Guide" type="hidden" />
                                <img id="Guide1" alt="" />
                            </div>
                        </div>
                    </div>
                    <div data-options="region:'center',split:false,title:'宽屏图'," style="height: 50%; overflow: hidden; padding: 1px;">
                        <div class="easyui-layout" data-options="fit:true,">
                            <div data-options="region:'north',split:false," style="height: 30px; overflow: hidden;">
                                <div style="float: left;">
                                    <a href="javascript:void(0)" class="easyui-linkbutton mp0" id="BannerAdd" data-options="iconCls:'icon-add1',plain:true,"></a>
                                    <a href="#" class="easyui-menubutton" data-options="menu:'#mmBanner',iconCls:'icon-edit',"></a>
                                    <div id="mmBanner" style="width: 150px;">
                                        <div id="BannerDelete" data-options="iconCls:'icon-cancel'">删除</div>
                                    </div>
                                </div>
                                <div style="float: right; padding: 2px 1px 0px 2px;">
                                </div>
                            </div>
                            <div data-options="region:'center',split:true," style="padding: 1px; text-align: center; overflow: auto;">
                                <input id="Banner" name="Banner" type="hidden" />
                                <img id="Banner1" alt="" src="/images/logo.jpg" />
                            </div>
                        </div>
                    </div>
                    <div data-options="region:'south',split:false,title:'小图标'," style="height: 20%; height: 120px; overflow: hidden; padding: 1px;">
                        <div class="easyui-layout" data-options="fit:true,">
                            <div data-options="region:'north',split:false," style="height: 30px; overflow: hidden;">
                                <div style="float: left;">
                                    <a href="javascript:void(0)" class="easyui-linkbutton mp0" id="IconAdd" data-options="iconCls:'icon-add1',plain:true,"></a>
                                    <a href="#" class="easyui-menubutton" data-options="menu:'#mmIcon',iconCls:'icon-edit',"></a>
                                    <div id="mmIcon" style="width: 150px;">
                                        <div id="IconDelete" data-options="iconCls:'icon-cancel'">删除</div>
                                    </div>
                                </div>
                                <div style="float: right; padding: 2px 1px 0px 2px;">
                                </div>
                            </div>
                            <div data-options="region:'center',split:true," style="padding: 1px; text-align: center; overflow: auto;">
                                <input id="Icon" name="Icon" type="hidden" />
                                <img id="Icon1" alt="" />
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</form>
<script type="text/javascript">
(function ($) {
    window.xbase.logonNo(); // 访问本页面，如已登录则跳转到index.html。
    window.xbase.closeDialog('#btnClose', '#dialog1');
    window.xbase.openDialog('#btnHelp', '#dialog2', '/Html/Acc/Staff/HelpListForm.html', '系统帮助');
    var action = $('#Action').val();
    var dgid = window.xbase.getDataGridItem('#datagrid1');
    var tvid = window.xbase.getTreeViewItem('#treeview1');
    var nodeId = action == 'ActNew' ? (tvid ? tvid : 0) : (dgid ? dgid : 0);
    var datas = 'id=' + nodeId + '&action=' + action + '&url=' + window.location.pathname + '&rnd=' + Math.random();
    editorBuilder('Content');//在使用编辑前就要生成。
    $.ajax({
        url: '/Ashx/Acc/Staff/NewsAdminNodeView.ashx?' + datas,
        data: datas,
        method: 'post',
        success: function (result) {
            var json = window.xbase.json(result);
            $('#formx').form('load', json);
            KindEditor.html('#Content', json.Content);
            //$('#Content').html(json.Content);
            $("#Banner1").attr("src", json.Banner);
            $("#Guide1").attr("src", json.Guide);
            $("#Icon1").attr("src", json.Icon);
        },
    });
    $('#btnSave').click(function () {
        $('#formx').form('submit', {
            url: '/Ashx/Acc/Staff/NewsAdminNodeFormSubmit.ashx?' + datas,
            dataType: 'json',
            data: datas,
            success: function (result) {
                if (result == null || result == '') return window.xbase.return('系统错误', 'Ajax返回空值，请稍后重试！<br />ps:如果您使用了360浏览器，请换之！', 'error');
                var json = window.xbase.json(result);
                if (json.error == 0) {
                    var node = $('#treeview1').tree('getSelected'); //取得所选择的树节点
                    if (!node) //未选择树节点则重载根
                        $('#treeview1').tree('reload');
                    else {
                        $('#treeview1').tree('expand', node.target); //必须先展开，再追加数据。
                        if (action == 'ActNew') {//新增数据则在所选节点的下级的最后追加
                            $('#treeview1').tree('append', {
                                parent: node.target,
                                data: [{ id: json.id, text: json.text, attributes: json.attributes, }]
                            });
                        }
                        if (action == 'ActEdit') $('#treeview1').tree('reload', node.target);
                    }
                    $("#datagrid1").datagrid('reload');
                    $('#dialog1').dialog('close');
                }
                $.messager.alert('提示信息', json.message.m_StringValue, 'info');
            }
        });
    });
    $('#BannerAdd').click(function () { imagesManager('#Banner', '#Banner1'); });
    $('#BannerDelete').click(function () { $("#Banner1").attr("src", ""); $('#Banner').val(""); });
    $('#BannerStop').click(function () { });
    $('#GuideAdd').click(function () { imagesManager('#Guide', '#Guide1'); });
    $('#GuideDelete').click(function () { $("#Guide1").attr("src", ""); $('#Guide').val(""); });
    $('#GuideStop').click(function () { });
    $('#IconAdd').click(function () { imagesManager('#Icon', '#Icon1'); });
    $('#IconDelete').click(function () { $("#Icon1").attr("src", ""); $('#Icon').val(""); });
    $('#IconStop').click(function () { });
    function imagesManager(obj, objsrc) {
        $.getScript('/ker/kindeditor-min.js', function () {
            if (!KindEditor) throw "KindEditor is not defined！";
            var editor = KindEditor.editor({
                allowFileManager: true, //允许选择已上传的图片
                basePath: '/ker/',
                pluginsPath: '/ker/plugins/',
                themesPath: '/ker/themes/',
                langPath: "/ker/lang/",
                uploadJson: '/ashx/app/UploadFiles.ashx',
                fileManagerJson: '/ashx/app/UploadFilesBrowser.ashx',
            });
            //debugger;
            editor.loadPlugin('image', function () {
                editor.plugin.imageDialog({
                    imageUrl: $(obj).val(),
                    clickFn: function (url, title, width, height, border, align) {
                        $(obj).val(url);
                        $(objsrc).attr("src", url);
                        editor.hideDialog();
                    }
                });
            });
        });
    }
    window.setTimeout(function () { resize('#tabsIndex'); }, 1000);
    function resize(tabsIndex) {
        var height = $('#tabsContent').parent().height() - 35;
        //$(tabsIndex).height(height);
        $(tabsIndex).css("height", height);
        $(tabsIndex).css("overflow-x", 'hidden');
        $(tabsIndex).css("overflow-y", 'scroll');
    }
    function editorBuilder(content) {
        $.getScript('/ker/kindeditor-min.js', function () {
            if (!KindEditor) throw "KindEditor is not defined!!!";
            KindEditor.basePath = '/ker/';
            KindEditor.remove('textarea[name="' + content + '"]');
            KindEditor.create('textarea[name="' + content + '"]', {
                themeType: 'simple',
                langType: 'zh_CN', // this.value,
                urlType: 'absolute', //relative|absolute|domain
                uploadJson: '/ashx/app/UploadFiles.ashx',
                fileManagerJson: '/ashx/app/UploadFilesBrowser.ashx',
                allowFileManager: true,
                autoHeightMode: true,
                afterCreate: function () {
                    this.loadPlugin('autoheight');
                },
                afterBlur: function () { this.sync(); },
                afterChange: function () //输入文字事件
                {
                    //1.判断是否是IE，并获取内容高度 //2.设置高度
                    this.edit.setHeight(KindEditor.IE ? this.edit.doc.body.scrollHeight : this.edit.doc.body.offsetHeight);
                }
            });
        });
    }
})(jQuery);
</script>
</body>
</html>
